class_name StructFactory

static var struct_msg = preload("res://script/struct/struct_message.gd")

static var g_msg_name_map = {}
static var g_msg_id_map = {}
static var is_initialize = false

static func _register_message(msg_cls):
	g_msg_name_map[msg_cls.proto_name] = msg_cls.proto_id
	g_msg_id_map[msg_cls.proto_id] = msg_cls

static func initialize():
	if is_initialize:
		return
	is_initialize = true
	_register_message(struct_msg.CS2C_SyncServerTime)


static func create_struct_msg(msg_id):
	var cls = g_msg_id_map.get(msg_id)
	if not cls:
		return null
	return cls.new()
	
static func get_proto_id(msg):
	return g_msg_name_map.get(msg.proto_name)
